package com.lfm.park.Service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lfm.park.Service.TemporaryService;
import com.lfm.park.dao.TemporaryMapper;
import com.lfm.park.model.Temporary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lfm
 * @date 2020/3/17 - 11:50
 */
@Service
public class TemporaryServiceImpl implements TemporaryService {
    @Resource
    private TemporaryMapper temporaryMapper;
    @Override
    public Temporary selectById(Integer id) {
        return temporaryMapper.selectById(id);
    }

    @Override
    public PageInfo<Temporary> selectAllTemporary(Temporary temporary, int page, int size) {
        PageHelper.startPage(page, size);
        // 查询分页信息 调用方式与普通方式一致
        List<Temporary> list = temporaryMapper.selectAllTemporary(temporary);
        //生成PageInfo对象
        PageInfo<Temporary> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void addTemporary(Temporary temporary) {
        temporaryMapper.addTemporary(temporary);
    }

    @Override
    public void updateTemporary(Temporary temporary) {
        temporaryMapper.updateTemporary(temporary);
    }

    @Override
    public void deleteTemporary(Temporary temporary) {
        temporaryMapper.deleteTemporary(temporary);
    }
}
